﻿@{
    ViewBag.Title = "Groups";
}
@model IEnumerable<Auction_Intranet.Models.UserGroupModel>
<div class="page">
    <h2 class="page-title">Groups</h2>

    @foreach (var item in Model)
    {
        <section class="groups-item black-shadow-box">
                <aside class="groups-item-1 col3 groups-info">
                    <span class="groups-item-text"><span class="groups-item-titles">Name:</span><span class="groups-item-data">@FileHelper.Truncate(item.group.Name,20)</span></span><br />
                    <span class="groups-item-text"><span class="groups-item-titles">Balance:</span><span class="groups-item-data">@item.group.Balance </span></span><br />
                    <span class="groups-item-text"><span class="groups-item-titles">Created:</span><span class="groups-item-data">@item.group.Created.ToLongDateString()</span></span><br />
                    <span class="groups-item-text"><span class="groups-item-titles">Number of members:</span><span class="groups-item-data">@item.groupMembers.Count</span></span><br />
                    @if(item.numberOfPendingInvitations > 0)
                    {
                        <span class="groups-item-text"><span class="groups-item-titles group-invitations-icon">@Html.ActionLink("Pending invitations", "PendingInvitations", new { id = item.group.Id }, new { title = "Pending Invitation" }):</span> <span class="groups-item-data">@item.numberOfPendingInvitations</span></span><br />                 
                    }
                    <span class="groups-item-text"><span class="groups-item-titles group-bids-icon">@Html.ActionLink("Bids", "GroupBids", new { id = item.group.Id }, new { title = "Group Bids" }):</span> <span class="groups-item-data">@item.numberOfBids</span></span><br />                                          
                </aside>                 
                <aside class="groups-item-2 col3 groups-info">
                    <span class="groups-item-text groups-members"><span class="groups-members-title">Members:</span>                     
                    @foreach (var member in item.groupMembers)
                    {                        
                        <span class="groups-item-members-data">@Html.ActionLink(FileHelper.Truncate(member.User.Username, 15), "UserInfo", "Groups", new { id = member.User.Id, groupid = member.GroupId }, new { title = "User Information" }) | added - @member.CreditAdded | spent - @member.CreditAddedSpent</span><br />
                    }
                    </span>
                    </aside> 
                <aside class="groups-item-3 col3">
                    <span class="groups-item-text dialog-leave-group">
                     @if ((item.groupMembers.Count + item.numberOfPendingInvitations) < 8)
                     { 
                            @Html.ActionLink("invite", "Invite", new { id = item.group.Id }, new { title = "Invite Member to Group." }) <span>|</span> 
                     } 
                        @Html.ActionLink("leave", "Leave", new { id = item.group.Id }, new { title = "Leave Group." }) | 
                        @Html.ActionLink("add credit", "AddCredit", new { id = item.group.Id }, new { title = "Add Credit to Group." })
                    </span>        
                </aside>
        </section>
    }
</div>

